package com.tsu.mall.admin.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//登录拦截
public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Boolean b=request.getSession().getAttribute("currentAttendant")!=null;
        if(!b){//没登陆
            response.sendRedirect("/login");
        }else {//登录了
            return true;
        }
        return false;
    }


}
